/**
 *  @file
 *  @brief   Z形（Z）梁截面属性使用解析公式计算类
 *  @author  duweixing
 *  @date    2024.04.23
 *  @version v1.0
 *  @par Copyright(c):  ShenGong  Simulation corporation
 */

#include "ZSectionFormulaCalculator.h"
#include "DataStructure/Common/Real.h"

using SG::DataStructure::Common::Real;
using SG::DataStructure::FEM::PBARLData;
using SG::DataStructure::FEM::PBARData;
using SG::FEMSolver::Element::ZSectionFormulaCalculator;

void ZSectionFormulaCalculator::Compute
(
const SG::DataStructure::FEM::PBARLData& section,
_OUT SG::DataStructure::FEM::PBARData&   property,
_OUT SG::Algebra::Point&                 centroid
) const
{
    Real bf{section.m_dimension[0]};
    Real tw{section.m_dimension[1]};
    Real hw{section.m_dimension[2]};
    Real h{section.m_dimension[3]};
    Real b{bf + tw};
    Real tf{0.5 * (h - hw)};

    property.m_id  = section.m_id;
    property.m_mId = section.m_mId;
    property.m_A   = h * tw + 2.0 * bf * tf;
    // Real yS = 0.0;
    // Real zS = 0.0;
    // Real yC = 0.0;
    // Real zC = 0.0;
    property.m_I1  = tw * hw * hw * hw / 12.0 + (b * tf * tf * tf / 12.0 + b * tf * 0.25 * (hw + tf) * (hw + tf)) * 2.0;
    property.m_I2  = hw * tw * tw * tw / 12.0 + (tf * b * b * b / 12.0 + tf * b * 0.25 * (b - tw) * (b - tw)) * 2.0;
    property.m_I12 = -bf * tf * (hw + tf) * (tw + bf) * 0.5;
    property.m_J   = (hw * tw * tw * tw + 2.0 * b * tf * tf * tf) / 3.0;
    property.m_K1  = hw * tw / property.m_A;
    property.m_K2  = 2.0 * bf * tf / property.m_A;
    property.m_NSM = section.m_nsm;
    property.m_FE  = 0.0;
    property.SetStressPoints ({ 0.5 * h,  0.5 * tw,
                               -0.5 * h,  0.5 * tw + bf,
                               -0.5 * h, -0.5 * tw,
                                0.5 * h, -0.5 * tw - bf});
    centroid.m_x = 0.0;
    centroid.m_y = 0.0;
    centroid.m_z = 0.0;
}